﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Serialization;

namespace Kimd.Motion
{
    [Serializable]
    [XmlInclude(typeof(MultiAxisMoveStep))]
    [XmlInclude(typeof(SingleAxisMoveStep))]
    [XmlInclude(typeof(SingleAxisGoHomeStep))]
    [XmlInclude(typeof(DigitalOutputStep))]
    [XmlInclude(typeof(DelayStep))]
    [XmlInclude(typeof(DigitalInputStep))]
    public class Step : ICloneable
    {
        public string Description { get; set; }
        public StepType StepType { get; set; }
        public Step()
        {

        }

        public Step(string description, StepType stepType)
        {
            this.Description = description;
            this.StepType = stepType;
        }
        public virtual bool Run(Dictionary<string, Axis> machineAxis, Dictionary<string, Cylinder> machineCylinder, Dictionary<string, Sensor> machineSensor, out string errInfo)
        {
            errInfo = "";
            return true;
        }
        public virtual void Stop(Dictionary<string, Axis> machineAxis)
        {

        }
        public virtual TreeNode ToTreeNode()
        {
            return null;
        }
        public virtual void Prepare(Dictionary<string, Axis> machineAxis, Dictionary<string, Cylinder> machineCylinder, Tray tray = null, int trayIndex = -1, int nozzleIndex = -1)
        {

        }

        public object Clone()
        {
            return MemberwiseClone();
        }
    }

    public enum StepType
    {
        MultiAxisMove,
        SingleAxisMove,
        SingleAxisGoHome,
        DigitalOutput,
        Delay,
        DigitalInput,
    }
}
